package com.example.demo.web;

import com.example.demo.pojo.AqiFeedback;
import com.example.demo.service.IAqiFeedbackService;
import com.example.demo.vos.AfPageRequestDto;
import com.example.demo.vos.PageResponseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/aqiFeedback")
@CrossOrigin("*")
public class AqiFeedbackWeb {

    @Autowired
    private IAqiFeedbackService aqiFeedbackService;

    @RequestMapping("/saveAqiFeedback")
    public int saveAqiFeedback(@RequestBody AqiFeedback aqiFeedback) {
        return aqiFeedbackService.saveAqiFeedback(aqiFeedback);
    }

    @RequestMapping("/listAqiFeedbackByTelId")
    public List<AqiFeedback> listAqiFeedbackByTelId(@RequestBody AqiFeedback aqiFeedback) {
        return aqiFeedbackService.listAqiFeedbackByTelId(aqiFeedback.getTelId());
    }

    @RequestMapping("/listAqiFeedbackPage")
    public PageResponseDto<AqiFeedback> listAqiFeedbackPage(@RequestBody AfPageRequestDto afPageRequestDto) {
        return aqiFeedbackService.listAqiFeedbackPage(afPageRequestDto);
    }

    @RequestMapping("/getAqiFeedbackById")
    public AqiFeedback getAqiFeedbackById(@RequestBody AqiFeedback aqiFeedback) {
        return aqiFeedbackService.getAqiFeedbackById(aqiFeedback.getAfId());
    }

    @RequestMapping("/updateAqiFeedbackAssign")
    public int updateAqiFeedbackAssign(@RequestBody AqiFeedback aqiFeedback) {
        return aqiFeedbackService.updateAqiFeedbackAssign(aqiFeedback);
    }

    @PostMapping("/listAqiFeedbackByGmId")
    public List<AqiFeedback> listAqiFeedbackByGmId(@RequestBody AqiFeedback aqiFeedback) {
        System.out.println("调用成功，gmId = " + aqiFeedback.getGmId());
        System.out.println("接收到 state = " + aqiFeedback.getState());
        return aqiFeedbackService.listAqiFeedbackByGmId(aqiFeedback);
    }

    @RequestMapping("/updateAqiFeedbackState")
    public int updateAqiFeedbackState(@RequestBody AqiFeedback aqiFeedback) {
        return aqiFeedbackService.updateAqiFeedbackState(aqiFeedback);
    }

}
